package org.example.cicdi.service.impl.second;


import org.example.codegenerate.modelext.WebVo.domian.column.ColumnVoDomain;
import org.example.codegenerate.modelext.WebVo.domian.table.WebModelVo;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.util.List;

@Service
public class DbVoAnnotatonImpleServiceSecond implements FieldAnnotationServiceSecond {

	@Override
	public String getCode() {
		return "";//EnumWhiteColumnAnnotation.DbVo.getCode();//暂时不用这个，因为JPA的特性映射的时候，会存在问题
	}

	/*@Override
	public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column, TableVoDomain tableVoDomain, List<WebModelVo> webModelVoList) {
		DbVo db = column.getDbVo();
		if (db == null) {
			db = new DbVo();
			column.setDbVo(db);
		}

		if (field.getAnnotation(org.jeecg.modules.codegenerate.modelext.WebVo.annotation.Column.DbVo.class) != null) {
			org.jeecg.modules.codegenerate.modelext.WebVo.annotation.Column.DbVo vo = field.getAnnotation(org.jeecg.modules.codegenerate.modelext.WebVo.annotation.Column.DbVo.class);
			//db.setDbDefaultVal(null); //如果这里要实现的话，需要单独开个方法：jpa对象->class.newInstance()->反射获取字段值
			if(vo.dbFieldName().length()>0){
				db.setDbFieldName(vo.dbFieldName());
			}else {
				db.setDbFieldName(field.getName());
			}


			*//*String comment = vo.columnDefinition().toLowerCase();
			if (StringUtils.isNotBlank(comment)) {
				db.setDbFieldTxt(comment.substring(comment.indexOf("'") + 1, comment.length() - 1));
			}else {
				db.setDbFieldTxt("");
			}*//*
			db.setDbFieldTxt(vo.dbFieldTxt().toLowerCase());
			//db.setDbIsKey(vo.unique() ? 1 : 0);
			if(field.getAnnotation(Id.class) != null){
				db.setDbIsKey(1);
				db.setDbIsNull(0);
			}else {
				db.setDbIsKey(0);
				db.setDbIsNull(vo.dbIsNull());
			}

			db.setDbLength(vo.dbLength());
			db.setDbPointLength(vo.dbPointLength());
			if(vo.enumDbType().getJavatypesimplename().equalsIgnoreCase(field.getType().getSimpleName())){
				//如果默认值或者用户输入值相等，那么直接进行赋值
				db.setDbType(field.getType().getSimpleName());
			}else {
				db.setDbType(vo.enumDbType().getJavatypesimplename());
			}
			*//*if(field.getType().getSimpleName().equalsIgnoreCase("Date")
					||field.getType().getSimpleName().equalsIgnoreCase("BigDecimal")
						||field.getType().getSimpleName().equalsIgnoreCase("String")) {
					db.setDbType(field.getType().getSimpleName());
				if(vo.columnDefinition().toLowerCase().contains("text")){//处理一下Text类型的问题
					db.setDbType("Text");
				}
			}else {
				db.setDbType(field.getType().getSimpleName().toLowerCase());
			}*//*
			//db.setDbPointLength(vo.scale());


			//special设置，没有从注解上进行设置
			db.setDbDefaultVal(null);
			db.setValidateVo(null);

			//db.setFieldName(oConvertUtils.camelName(db.getDbFieldName()));
			db.setFieldName(db.getDbFieldName());
			//db.setFieldType(new OnlCgformHeadService10Impl().getWrapper(db.getDbType()));
			AuxHelper.getWrapper(db.getDbType());

			column.setDbVo(db);
		}

		return column;
	}*/
	//这个方法中传入了WebModelVo，及WebModelVoList没有作用
	public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column, WebModelVo webModelVo, List<WebModelVo> webModelVoList){
		return null;
	}
}
